package com.study;
/*
 *
 *  长、宽、半径、形状
 *  计算周长、计算面积。
 *
 * */

public class Shape01 {
    int width;
    int height;
    int radius;
    String shape;
    Shape01(){};
    Shape01(int[] arr){
        if (arr.length == 2){
            this.width = arr[0];
            this.height = arr[1];
            this.shape = "长方形";

        }else{
            this.radius = arr[0];
            this.shape = "圆";
        }
    }

    public double perimeter(){
        if (this.shape == "长方形"){
            return (this.width + this.height)*2;
        }else {
            return (2*3.14*this.radius);
        }

    }
    public double area(){
        if (this.shape == "长方形"){
            return (double) (this.width * this.height);
        }else {
            return (3.14 * this.radius * this.radius);
        }
    }

}
